package com.tgy;

/**
 * @Author: tgy
 * @Date: 2020-09-07 10:17
 */
public class Deque<E> {

    private LinkedList<E> linkedList;

    public Deque() {


        linkedList = new LinkedList();
    }

    public boolean isEmpty() {

        return linkedList.isEmpty();
    }

    void addFirst(E e){

        linkedList.add(0,e);
    }


    void addLast(E e) {

        linkedList.add(e);
    }


    E removeFirst() {

        return linkedList.remove(0);
    }


    E removeLast() {

        return linkedList.remove(linkedList.size() - 1);
    }



    E getFirst() {

        return removeFirst();
    }


    E getLast() {

        return removeLast();
    }


    E peekFirst() {

        return linkedList.get(0);
    }


    E peekLast() {

        return linkedList.get(linkedList.size() - 1);
    }

    @Override
    public String toString() {

        return linkedList.toString();
    }
}
